/**
 * Created by huachuan on 2016/1/9.
 */
angular.module('discovermemberservice',[])
  //约局的Service
  .factory('DiscoverMember', function($resource,$rootScope,ENV){

    //访问的地址
    var APIUrl = ENV.api;
    //接收返回值
    var attendmemberJson,memberListJson;
    //存储的key
    //获取$resource
    var getAttendMemberResource = $resource(APIUrl+'releaseMeeting/getAttendMember.do');
    var findMemberListByKeyResource = $resource(APIUrl+'meAttention/searchMemberList.do');
    return{
      findMemberListByKey:function(searchKey){
        findMemberListByKeyResource.save({
          searchKey:searchKey
        },function(response){
          memberListJson = response;
          $rootScope.$broadcast('DiscoverMember.memberListByKeyUpdated');
        });
      },
      getMemberListJson:function(){
            return memberListJson;
      },
      //获取关注我，我关注的列表，会员姓名首字母排序的列表
      getAttendMemberList:function(memberId){
        getAttendMemberResource.save({
          member_id:memberId
        },function(response){
          attendmemberJson = response;
          $rootScope.$broadcast('DiscoverMember.attendMemberListUpdated');
        });
      },
      getAttendMemberListJson:function(){
        return attendmemberJson;
      }
    }
  });
